<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <title>cmake_parse_arguments &mdash; CMake 4.1.1 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=a2c47e09" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css?v=4d06bd55" />
    
    <script src="../_static/documentation_options.js?v=e6a937a4"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="cmake_path" href="cmake_path.html" />
    <link rel="prev" title="cmake_minimum_required" href="cmake_minimum_required.html" />
 

  </head><body>
    <input id="sidebar-check" type="checkbox" />
    <label id="sidebar-overlay" for="sidebar-check"></label>



    <div class="related relbar1" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="cmake_path.html" title="cmake_path"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="cmake_minimum_required.html" title="cmake_minimum_required"
             accesskey="P">previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-commands.7.html" accesskey="U">cmake-commands(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">cmake_parse_arguments</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="cmake-parse-arguments">
<span id="command:cmake_parse_arguments"></span><h1>cmake_parse_arguments<a class="headerlink" href="#cmake-parse-arguments" title="Link to this heading">¶</a></h1>
<p>Parse function or macro arguments.</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">cmake_parse_arguments(</span><span class="nv">&lt;prefix&gt;</span><span class="w"> </span><span class="nv">&lt;options&gt;</span><span class="w"> </span><span class="nv">&lt;one_value_keywords&gt;</span>
<span class="w">                      </span><span class="nv">&lt;multi_value_keywords&gt;</span><span class="w"> </span><span class="nv">&lt;args&gt;...</span><span class="nf">)</span>

<span class="nf">cmake_parse_arguments(</span><span class="no">PARSE_ARGV</span><span class="w"> </span><span class="nv">&lt;N&gt;</span><span class="w"> </span><span class="nv">&lt;prefix&gt;</span><span class="w"> </span><span class="nv">&lt;options&gt;</span>
<span class="w">                      </span><span class="nv">&lt;one_value_keywords&gt;</span><span class="w"> </span><span class="nv">&lt;multi_value_keywords&gt;</span><span class="nf">)</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.5: </span>This command is implemented natively.  Previously, it has been defined in the
module <span class="target" id="index-0-module:CMakeParseArguments"></span><a class="reference internal" href="../module/CMakeParseArguments.html#module:CMakeParseArguments" title="CMakeParseArguments"><code class="xref cmake cmake-module docutils literal notranslate"><span class="pre">CMakeParseArguments</span></code></a>.</p>
</div>
<p>This command is for use in macros or functions.
It processes the arguments given to that macro or function,
and defines a set of variables which hold the values of the
respective options.</p>
<p>The first signature reads arguments passed in the <code class="docutils literal notranslate"><span class="pre">&lt;args&gt;...</span></code>.
This may be used in either a <span class="target" id="index-0-command:macro"></span><a class="reference internal" href="macro.html#command:macro" title="macro"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">macro()</span></code></a> or a <span class="target" id="index-0-command:function"></span><a class="reference internal" href="function.html#command:function" title="function"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">function()</span></code></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.7: </span>The <code class="docutils literal notranslate"><span class="pre">PARSE_ARGV</span></code> signature is only for use in a <span class="target" id="index-1-command:function"></span><a class="reference internal" href="function.html#command:function" title="function"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">function()</span></code></a>
body.  In this case, the arguments that are parsed come from the
<code class="docutils literal notranslate"><span class="pre">ARGV#</span></code> variables of the calling function.  The parsing starts with
the <code class="docutils literal notranslate"><span class="pre">&lt;N&gt;</span></code>-th argument, where <code class="docutils literal notranslate"><span class="pre">&lt;N&gt;</span></code> is an unsigned integer.
This allows for the values to have special characters like <code class="docutils literal notranslate"><span class="pre">;</span></code> in them.</p>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;options&gt;</span></code> argument contains all options for the respective function
or macro. These are keywords that have no value following them, like the
<code class="docutils literal notranslate"><span class="pre">OPTIONAL</span></code> keyword of the <span class="target" id="index-0-command:install"></span><a class="reference internal" href="install.html#command:install" title="install"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">install()</span></code></a> command.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code> argument contains all keywords for this function
or macro which are followed by one value, like the <code class="docutils literal notranslate"><span class="pre">DESTINATION</span></code> keyword of
the <span class="target" id="index-1-command:install"></span><a class="reference internal" href="install.html#command:install" title="install"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">install()</span></code></a> command.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">&lt;multi_value_keywords&gt;</span></code> argument contains all keywords for this
function or macro which can be followed by more than one value, like the
<code class="docutils literal notranslate"><span class="pre">TARGETS</span></code> or <code class="docutils literal notranslate"><span class="pre">FILES</span></code> keywords of the <span class="target" id="index-2-command:install"></span><a class="reference internal" href="install.html#command:install" title="install"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">install()</span></code></a> command.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.5: </span>All keywords must be unique.  Each keyword can only be specified
once in any of the <code class="docutils literal notranslate"><span class="pre">&lt;options&gt;</span></code>, <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code>, or
<code class="docutils literal notranslate"><span class="pre">&lt;multi_value_keywords&gt;</span></code>. A warning will be emitted if uniqueness is
violated.</p>
</div>
<p>When done, <code class="docutils literal notranslate"><span class="pre">cmake_parse_arguments</span></code> will consider for each of the
keywords listed in <code class="docutils literal notranslate"><span class="pre">&lt;options&gt;</span></code>, <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code>, and
<code class="docutils literal notranslate"><span class="pre">&lt;multi_value_keywords&gt;</span></code>, a variable composed of the given <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;</span></code>
followed by <code class="docutils literal notranslate"><span class="pre">&quot;_&quot;</span></code> and the name of the respective keyword.  For
<code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">&lt;multi_value_keywords&gt;</span></code>, these variables
will then hold the respective value(s) from the argument list, or be undefined
if the associated keyword was not given (policy <span class="target" id="index-0-policy:CMP0174"></span><a class="reference internal" href="../policy/CMP0174.html#policy:CMP0174" title="CMP0174"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0174</span></code></a> can also
affect the behavior for <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code>).  For the <code class="docutils literal notranslate"><span class="pre">&lt;options&gt;</span></code>
keywords, these variables will always be defined, and they will be set to
<code class="docutils literal notranslate"><span class="pre">TRUE</span></code> if the keyword is present, or <code class="docutils literal notranslate"><span class="pre">FALSE</span></code> if it is not.</p>
<p>All remaining arguments are collected in a variable
<code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;_UNPARSED_ARGUMENTS</span></code> that will be undefined if all arguments
were recognized. This can be checked afterwards to see
whether your macro or function was called with unrecognized parameters.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 3.15: </span><code class="docutils literal notranslate"><span class="pre">&lt;one_value_keywords&gt;</span></code> and <code class="docutils literal notranslate"><span class="pre">&lt;multi_value_keywords&gt;</span></code> that were given no
values at all are collected in a variable
<code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;_KEYWORDS_MISSING_VALUES</span></code> that will be undefined if all keywords
received values. This can be checked to see if there were keywords without
any values given.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.31: </span>If a <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keyword&gt;</span></code> is followed by an empty string as its value,
policy <span class="target" id="index-1-policy:CMP0174"></span><a class="reference internal" href="../policy/CMP0174.html#policy:CMP0174" title="CMP0174"><code class="xref cmake cmake-policy docutils literal notranslate"><span class="pre">CMP0174</span></code></a> controls whether a corresponding
<code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;_&lt;keyword&gt;</span></code> variable is defined or not.</p>
</div>
<p>Choose a <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;</span></code> carefully to avoid clashing with existing variable names.
When used inside a function, it is usually suitable to use the prefix <code class="docutils literal notranslate"><span class="pre">arg</span></code>.
There is a very strong convention that all keywords are fully uppercase, so
this prefix results in variables of the form <code class="docutils literal notranslate"><span class="pre">arg_SOME_KEYWORD</span></code>.  This makes
the code more readable, and it minimizes the chance of clashing with cache
variables, which also have a strong convention of being all uppercase.</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">function(</span><span class="nb">my_install</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">options</span><span class="w"> </span><span class="no">OPTIONAL</span><span class="w"> </span><span class="no">FAST</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">oneValueArgs</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="no">RENAME</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">multiValueArgs</span><span class="w"> </span><span class="no">TARGETS</span><span class="w"> </span><span class="no">CONFIGURATIONS</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">cmake_parse_arguments(</span><span class="no">PARSE_ARGV</span><span class="w"> </span><span class="m">0</span><span class="w"> </span><span class="nb">arg</span>
<span class="w">        </span><span class="s">&quot;${options}&quot;</span><span class="w"> </span><span class="s">&quot;${oneValueArgs}&quot;</span><span class="w"> </span><span class="s">&quot;${multiValueArgs}&quot;</span>
<span class="w">    </span><span class="nf">)</span>

<span class="w">    </span><span class="c"># The above will set or unset variables with the following names:</span>
<span class="w">    </span><span class="c">#   arg_OPTIONAL</span>
<span class="w">    </span><span class="c">#   arg_FAST</span>
<span class="w">    </span><span class="c">#   arg_DESTINATION</span>
<span class="w">    </span><span class="c">#   arg_RENAME</span>
<span class="w">    </span><span class="c">#   arg_TARGETS</span>
<span class="w">    </span><span class="c">#   arg_CONFIGURATIONS</span>
<span class="w">    </span><span class="c">#</span>
<span class="w">    </span><span class="c"># The following will also be set or unset:</span>
<span class="w">    </span><span class="c">#   arg_UNPARSED_ARGUMENTS</span>
<span class="w">    </span><span class="c">#   arg_KEYWORDS_MISSING_VALUES</span>
</pre></div>
</div>
<p>When used inside a macro, <code class="docutils literal notranslate"><span class="pre">arg</span></code> might not be a suitable prefix because the
code will affect the calling scope.  If another macro also called in the same
scope were to use <code class="docutils literal notranslate"><span class="pre">arg</span></code> in its own call to <code class="docutils literal notranslate"><span class="pre">cmake_parse_arguments()</span></code>,
and if there are any common keywords between the two macros, the later call's
variables can overwrite or remove those of the earlier macro's call.
Therefore, it is advisable to incorporate something unique from the macro name
in the <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;</span></code>, such as <code class="docutils literal notranslate"><span class="pre">arg_lowercase_macro_name</span></code>.</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">macro(</span><span class="nb">my_install</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">options</span><span class="w"> </span><span class="no">OPTIONAL</span><span class="w"> </span><span class="no">FAST</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">oneValueArgs</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="no">RENAME</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">multiValueArgs</span><span class="w"> </span><span class="no">TARGETS</span><span class="w"> </span><span class="no">CONFIGURATIONS</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">cmake_parse_arguments(</span><span class="nb">arg_my_install</span>
<span class="w">        </span><span class="s">&quot;${options}&quot;</span><span class="w"> </span><span class="s">&quot;${oneValueArgs}&quot;</span><span class="w"> </span><span class="s">&quot;${multiValueArgs}&quot;</span>
<span class="w">        </span><span class="o">${</span><span class="nt">ARGN</span><span class="o">}</span>
<span class="w">    </span><span class="nf">)</span>
<span class="w">    </span><span class="c"># ...</span>
<span class="nf">endmacro()</span>

<span class="nf">macro(</span><span class="nb">my_special_install</span><span class="nf">)</span>
<span class="w">    </span><span class="c"># NOTE: Has the same keywords as my_install()</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">options</span><span class="w"> </span><span class="no">OPTIONAL</span><span class="w"> </span><span class="no">FAST</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">oneValueArgs</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="no">RENAME</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">set(</span><span class="nb">multiValueArgs</span><span class="w"> </span><span class="no">TARGETS</span><span class="w"> </span><span class="no">CONFIGURATIONS</span><span class="nf">)</span>
<span class="w">    </span><span class="nf">cmake_parse_arguments(</span><span class="nb">arg_my_special_install</span>
<span class="w">        </span><span class="s">&quot;${options}&quot;</span><span class="w"> </span><span class="s">&quot;${oneValueArgs}&quot;</span><span class="w"> </span><span class="s">&quot;${multiValueArgs}&quot;</span>
<span class="w">        </span><span class="o">${</span><span class="nt">ARGN</span><span class="o">}</span>
<span class="w">    </span><span class="nf">)</span>
<span class="w">    </span><span class="c"># ...</span>
<span class="nf">endmacro()</span>
</pre></div>
</div>
<p>Suppose the above macros are called one after the other, like so:</p>
<div class="highlight-cmake notranslate"><div class="highlight"><pre><span></span><span class="nf">my_install(</span><span class="no">TARGETS</span><span class="w"> </span><span class="nb">foo</span><span class="w"> </span><span class="nb">bar</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="nb">bin</span><span class="w"> </span><span class="no">OPTIONAL</span><span class="w"> </span><span class="nb">blub</span><span class="w"> </span><span class="no">CONFIGURATIONS</span><span class="nf">)</span>
<span class="nf">my_special_install(</span><span class="no">TARGETS</span><span class="w"> </span><span class="nb">barry</span><span class="w"> </span><span class="no">DESTINATION</span><span class="w"> </span><span class="nb">sbin</span><span class="w"> </span><span class="no">RENAME</span><span class="w"> </span><span class="no">FAST</span><span class="nf">)</span>
</pre></div>
</div>
<p>After these two calls, the following describes the variables that will be
set or unset:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>arg_my_install_OPTIONAL = TRUE
arg_my_install_FAST = FALSE # was not present in call to my_install
arg_my_install_DESTINATION = &quot;bin&quot;
arg_my_install_RENAME &lt;UNSET&gt; # was not present
arg_my_install_TARGETS = &quot;foo;bar&quot;
arg_my_install_CONFIGURATIONS &lt;UNSET&gt; # was not present
arg_my_install_UNPARSED_ARGUMENTS = &quot;blub&quot; # nothing expected after &quot;OPTIONAL&quot;
arg_my_install_KEYWORDS_MISSING_VALUES = &quot;CONFIGURATIONS&quot; # value was missing

arg_my_special_install_OPTIONAL = FALSE # was not present
arg_my_special_install_FAST = TRUE
arg_my_special_install_DESTINATION = &quot;sbin&quot;
arg_my_special_install_RENAME &lt;UNSET&gt; # value was missing
arg_my_special_install_TARGETS = &quot;barry&quot;
arg_my_special_install_CONFIGURATIONS &lt;UNSET&gt; # was not present
arg_my_special_install_UNPARSED_ARGUMENTS &lt;UNSET&gt;
arg_my_special_install_KEYWORDS_MISSING_VALUES = &quot;RENAME&quot;
</pre></div>
</div>
<p>Keywords terminate lists of values. If a keyword is given directly after a
<code class="docutils literal notranslate"><span class="pre">&lt;one_value_keyword&gt;</span></code>, that preceding <code class="docutils literal notranslate"><span class="pre">&lt;one_value_keyword&gt;</span></code> receives no
value and the keyword is added to the <code class="docutils literal notranslate"><span class="pre">&lt;prefix&gt;_KEYWORDS_MISSING_VALUES</span></code>
variable. In the above example, the call to <code class="docutils literal notranslate"><span class="pre">my_special_install()</span></code> contains
the <code class="docutils literal notranslate"><span class="pre">RENAME</span></code> keyword immediately followed by the <code class="docutils literal notranslate"><span class="pre">FAST</span></code> keyword.
In this case, <code class="docutils literal notranslate"><span class="pre">FAST</span></code> terminates processing of the <code class="docutils literal notranslate"><span class="pre">RENAME</span></code> keyword.
<code class="docutils literal notranslate"><span class="pre">arg_my_special_install_FAST</span></code> is set to <code class="docutils literal notranslate"><span class="pre">TRUE</span></code>,
<code class="docutils literal notranslate"><span class="pre">arg_my_special_install_RENAME</span></code> is unset, and
<code class="docutils literal notranslate"><span class="pre">arg_my_special_install_KEYWORDS_MISSING_VALUES</span></code> contains the value
<code class="docutils literal notranslate"><span class="pre">RENAME</span></code>.</p>
<section id="see-also">
<h2>See Also<a class="headerlink" href="#see-also" title="Link to this heading">¶</a></h2>
<ul class="simple">
<li><p><span class="target" id="index-2-command:function"></span><a class="reference internal" href="function.html#command:function" title="function"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">function()</span></code></a></p></li>
<li><p><span class="target" id="index-1-command:macro"></span><a class="reference internal" href="macro.html#command:macro" title="macro"><code class="xref cmake cmake-command docutils literal notranslate"><span class="pre">macro()</span></code></a></p></li>
</ul>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3>Table of Contents</h3>
    <ul>
<li><a class="reference internal" href="#">cmake_parse_arguments</a><ul>
<li><a class="reference internal" href="#see-also">See Also</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="cmake_minimum_required.html"
                          title="previous chapter">cmake_minimum_required</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="cmake_path.html"
                          title="next chapter">cmake_path</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/command/cmake_parse_arguments.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="cmake_path.html" title="cmake_path"
             >next</a> |</li>
        <li class="right" >
          <a href="cmake_minimum_required.html" title="cmake_minimum_required"
             >previous</a> |</li>
  <li>
    <label class="sidebar-toggle" for="sidebar-check"></label>
  </li>
  <li class="rootlink">
    <img src="../_static/cmake-logo-16.png" width="16" height="16" alt=""/>
    <a href="https://cmake.org/">CMake 4.1.1</a>
    <span class="reldelim1"> &#187;</span>
  </li>
  <li>
    <a href="../index.html">Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-commands.7.html" >cmake-commands(7)</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">cmake_parse_arguments</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
    &#169; Copyright 2000-2025 Kitware, Inc. and Contributors.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.1.3.
    </div>
<script type="text/javascript">
(function() {
  "use strict";
  const hide = () => document.getElementById("sidebar-check").checked = false;
  addEventListener("keydown", e => (e.key === "Escape") && hide());
  addEventListener("click", e => (e.target.tagName === "A") && hide());
  addEventListener("hashchange", hide)
})();
</script>
  </body>
</html>